package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 晓星航
 * Date: 2022-11-16
 * Time: 15:18
 */
class Shape {
    public void draw() {
        System.out.println("Shape::draw()");
    }
}

class Rect extends Shape {
    @Override
    public void draw() {
        System.out.println("♦");
    }
}

class Flower extends Shape {
    @Override
    public void draw() {
        System.out.println("❀");
    }
}

class Cycle extends Shape {
    @Override
    public void draw() {
        System.out.println("●");
    }
}
class Triangle extends Shape{
    @Override
    public void draw() {
        System.out.println("🔺");
    }
}

public class Test {
    public static void drawMap(Shape shape) {
        shape.draw();
    }
    public static void main(String[] args) {
        Rect rect = new Rect();
        drawMap(new Rect());
        Flower flower = new Flower();
        drawMap(new Flower());
        Triangle triangle = new Triangle();
        drawMap(new Triangle());
        System.out.println("===============================");
        Shape[] shapes = {triangle,rect,triangle,rect,flower,new Cycle()};
        for (Shape shape: shapes) {
            shape.draw();
        }
    }

    public static void main1(String[] args) {
        Shape shape1 = new Rect();
        shape1.draw();
        Shape shape2 = new Flower();
        shape2.draw();
    }
}
